local skels = {}

local xuelu = fk.CreateSkill{
    name = "XD__xuelu",
}
Fk:loadTranslationTable{
    ["XD__xuelu"] = "血路",
    [":XD__xuelu"] = "出牌阶段开始时，你可以失去1点体力并摸两张牌，然后本阶段你可以额外使用一张【杀】，且本阶段结束时，若你本阶段造成过至少2点伤害，你回复2点体力。你第一次以此法回复体力前，你加1点体力上限，然后将此技能改为锁定技。",
    ["XD__xueluEx"] = "血路",
    [":XD__xueluEx"] = "锁定技，出牌阶段开始时，你失去1点体力并摸两张牌，然后本阶段你可以额外使用一张【杀】，且本阶段结束时，若你本阶段造成过至少2点伤害，你回复2点体力。",
    ["@@XD__xuelu-phase"] = "血路",
}
xuelu:addEffect(fk.EventPhaseStart, {
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return target == player and player.phase == Player.Play and player:hasSkill(xuelu.name)
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:loseHp(player, 1, xuelu.name)
        player:drawCards(2, xuelu.name)
        room:setPlayerMark(player, "@@XD__xuelu-phase", 1)
    end,
})
xuelu:addEffect(fk.EventPhaseEnd, {
    anim_type = "support",
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
        return player:getMark("@@XD__xuelu-phase") > 0 and #player.room.logic:getActualDamageEvents(2, function(e)
            return e.data.from == player
        end, Player.HistoryPhase) > 1
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        if player:hasSkill(xuelu.name) then
            room:changeMaxHp(player, 1)
            room:handleAddLoseSkills(player, "-XD__xuelu|XD__xueluEx", nil, false, true)
        end
        room:recover{
            who = player,
            num = 2,
            skillName = xuelu.name
        }
    end,
})
xuelu:addEffect("targetmod",{
    residue_func = function(self, player, skill, scope)
        if skill.trueName == "slash_skill" and player:getMark("@@XD__xuelu-phase") > 0 and scope == Player.HistoryPhase then
            return 1
        end
    end,
})
table.insert(skels, xuelu)

local xueluEx = fk.CreateSkill{
    name = "XD__xueluEx",
    tags = {Skill.Compulsory},
}
xueluEx:addEffect(fk.EventPhaseStart, {
    can_trigger = function (self, event, target, player, data)
        return target == player and player.phase == Player.Play and player:hasSkill(xueluEx.name)
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:loseHp(player, 1, xuelu.name)
        player:drawCards(2, xuelu.name)
        room:setPlayerMark(player, "@@XD__xuelu-phase", 1)
    end,
})
table.insert(skels, xueluEx)

return skels